# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-screen-recorder
pkgver=5.12.12
pkgrel=1
pkgdesc='Deepin Screen Recorder'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/deepin-screen-recorder"
license=('GPL3')
depends=('deepin-qt5integration' 'deepin-qt-dbus-factory' 'dtkcore' 'dtkgui' 'dtkwidget'
         'qt5-base' 'qt5-x11extras' 'qt5-multimedia' 'deepin-turbo' 'ffmpeg' 'libxtst' 'opencv'
         'dconf' 'libxext' 'libx11' 'libxfixes' 'portaudio' 'deepin-image-editor' 'gcc-libs')
makedepends=('deepin-dock')
optdepends=('deepin-shortcut-viewer: for shortcut display')
provides=('deepin-screenshot')
conflicts=('deepin-screenshot')
groups=('deepin-extra')
source=("https://github.com/linuxdeepin/deepin-screen-recorder/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-unqualified-id.patch::https://github.com/linuxdeepin/deepin-screen-recorder/pull/416.patch)
sha512sums=('c8a8df7ef37394533fde0c7611fa70f03f5f42eb901574be5a4af481d4907f2dd41ce4339fec019a7f7e985d1dd0cf6633341c8a99bf097fb7a03c7f5c3c14fb'
            '5624a25292b0d4f74aa73c1374c51d9098db8a6984e9586da1f88349c0315e2dde1cb6f3b26ac7db6fd04044b9283238ab93a607be6883f746b0e1a57e8c3ce3')

prepare() {
  cd deepin-screen-recorder-$pkgver
  patch -Np1 -i ../$pkgname-unqualified-id.patch

  # https://github.com/linuxdeepin/developer-center/issues/3035
  sed -i "s|/etc/os-version|/etc/uos-version|" src/src.pro

  # OpenCV 4 compatibility
  sed -i '/#include<opencv2/i #include <opencv2/imgproc/types_c.h>' src/utils/pixmergethread.h

  # OpenCV missing in pkg-config targets
  sed -i 's/dframeworkdbus/dframeworkdbus opencv4/' src/src.pro
}

build(){
  cd deepin-screen-recorder-$pkgver
  qmake-qt5 PREFIX=/usr
  make
}

package() {
  cd deepin-screen-recorder-$pkgver
  make INSTALL_ROOT="$pkgdir" install
}
